package com.young.springboot.kafka;

/**
 * @description：
 * @author: yangyahui01
 * @date: 12/5/24 3:00 PM
 */
public abstract class RegexRecordFilter<V> implements RecordFilter<V> {

    private final AviatorRegexMatcher regexFilter;

    public RegexRecordFilter(String regex) {
        this.regexFilter = new AviatorRegexMatcher(regex);
    }

    @Override
    public boolean filter(V record) {
        String source = resolveSource(record);
        return !regexFilter.match(source);
    }


    public abstract String resolveSource(V record);
}
